<!DOCTYPE html>
<html>
<head>
	<title>动态绑定</title>
	<script type="text/javascript" src="jquery-3.2.1.js"></script>
</head>
<body>
	<label>请输入数字</label><input type="text" id="num" placeholder="请输入数字">
	<br>
	<button type="button" id="btm" onclick="add_ol()">确定</button>
	<button type="button" id="off">移除绑定</button>
	<p>列表</p>

	<script type="text/javascript">
		//var num=document.getElementById("btm").value;
		
		function add_ol(){
			var num=parseInt($("#num").val());
			$("#btm").attr("disabled","disabled")
			if (num!=0) {
				console.log(num);
				for (var i = 1; i < num+1; i++) {
					var text=$("<ol></ol>").text(i);
					$("p").append(text);
					};
				$("ol").on("click",function(e){
					alert($(e.target).text());
				});
				}
				$("#off").click(function(){
					$("ol").off("click");
				});
		
		}

		
	</script>
</body>
</html>